package com.future.future.movie.controller;

import java.util.Arrays;
import java.util.Map;

import com.future.future.commons.utils.PageUtils;
import com.future.future.commons.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.future.future.movie.entity.MovieTypeMiddleEntity;
import com.future.future.movie.service.MovieTypeMiddleService;




/**
 * 电影和电影类型中间表
 *
 * @author sn
 * @email sn@gmail.com
 * @date 2021-01-18 17:15:04
 */
@RestController
@RequestMapping("movie/movietypemiddle")
public class MovieTypeMiddleController {
    @Autowired
    private MovieTypeMiddleService movieTypeMiddleService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = movieTypeMiddleService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{movieTypeId}")
    public R info(@PathVariable("movieTypeId") Long movieTypeId){
		MovieTypeMiddleEntity movieTypeMiddle = movieTypeMiddleService.getById(movieTypeId);

        return R.ok().put("movieTypeMiddle", movieTypeMiddle);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody MovieTypeMiddleEntity movieTypeMiddle){
		movieTypeMiddleService.save(movieTypeMiddle);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody MovieTypeMiddleEntity movieTypeMiddle){
		movieTypeMiddleService.updateById(movieTypeMiddle);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] movieTypeIds){
		movieTypeMiddleService.removeByIds(Arrays.asList(movieTypeIds));

        return R.ok();
    }

}
